package com.m3839.sdk.common.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Description:用于一些通用的条件判断
 *
 * @author 陈宝阳
 * @create 2019/1/30
 */
public class FastClickUtils {

  public static final int MIN_CLICK_TIME = 800;

  /**
   * 防止短时间内点击两次
   */
  private static long lastClickTime;

  /**
   * 多次点击检测
   * @return
   */
  public static synchronized boolean isFastDoubleClick() {
    boolean result = false;
    long currentTime = System.currentTimeMillis();
    if ((currentTime - lastClickTime) < MIN_CLICK_TIME) {
      result = true;
    }
    lastClickTime = currentTime;
    return result;
  }

  public static boolean isNumeric(String str){
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(str);
    if( !isNum.matches() ){
      return false;
    }
    return true;
  }
}
